package com.myGroup.common;

/**
 * 基于ThreadLocal封装工具类，用户保存的获取当前登录的Id
 * 只在当前的线程进行作用域，各个线程互不影响
 */
public class BaseContext {
    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    /**
     * 设置id
      * @param id
     */
    public static void setCurrentId(Integer id) {
        threadLocal.set(id);
    }

    /**
     * 获取id
     * @return
     */
    public static Integer getCurrentId() {
        return threadLocal.get();
    }
}
